package com.example.polarity;

import android.graphics.Canvas;
import android.view.SurfaceHolder;

public class MainThread extends Thread 
{
	 private SurfaceHolder surfaceHolder;
	 private boolean running;

	 GameView GameObjects; 
	 
	 public void setRunning(boolean running) 
	 {
		 this.running = running;
	 }
	
	 public MainThread(SurfaceHolder surfaceHolder, GameView game) 
	 {
		 super();
		 this.surfaceHolder = surfaceHolder;
		 GameObjects = game;
	 }
	
	 @Override
	 public void run() 
	 {
		  Canvas canvas;
		  
		  while (running) 
		  {
			   canvas = null;
			   // try locking the canvas for exclusive pixel editing on the surface
			   try 
			   {
				   canvas = this.surfaceHolder.lockCanvas();
				   synchronized (surfaceHolder) 
				   {
					   
					  // GameObjects.player.Move(canvas, parent)
			       }
			   } 
			   finally
			   {
				    // in case of an exception the surface is not left in
				    // an inconsistent state
				    if (canvas != null) 
				    {
				    	surfaceHolder.unlockCanvasAndPost(canvas);
				    }
			   } // end finally
		  }
		  
	}

}